<?php

namespace App\Http\Requests\Admin\V1;

class MenuStoreRequest extends FormRequest
{
    /**
     * @expalin 验证规则
     * @return \string[][]
     * @method
     * @author 陈文小超
     * @maxim from专注to执行
     * @time 2021/4/1/11:06
     */
    public function rules()
    {
        return [
            'parent_id'      => ['bail', 'required', 'integer'],
            'name'           => ['bail', 'present', 'max:50'],
            'title'          => ['bail', 'required', 'max:20', 'unique:menus,title'],
            'icon'           => ['bail', 'present', 'max:50'],
            'path'           => ['bail', 'present', 'max:50'],
            'component_path' => ['bail', 'present', 'max:50'],
            'is_enable'      => ['bail', 'required', 'boolean'],
        ];
    }

    /**
     * @expalin 自定义错误
     * @return array
     * @method
     * @author 陈文小超
     * @maxim from专注to执行
     * @time 2021/4/1/11:10
     */
    public function messages()
    {
        return [
            'parent_id.required'     => trans('admin/v1/request.menu.parent_id-required'),
            'parent_id.integer'      => trans('admin/v1/request.menu.parent_id-integer'),
            'name.present'           => trans('admin/v1/request.menu.name-present'),
            'name.max'               => trans('admin/v1/request.menu.name-max'),
            'title.required'         => trans('admin/v1/request.menu.title-required'),
            'title.max'              => trans('admin/v1/request.menu.title-max'),
            'title.unique'           => trans('admin/v1/request.menu.title-unique'),
            'icon.present'           => trans('admin/v1/request.menu.icon-present'),
            'icon.max'               => trans('admin/v1/request.menu.icon-max'),
            'path.present'           => trans('admin/v1/request.menu.path-present'),
            'path.max'               => trans('admin/v1/request.menu.path-max'),
            'component_path.present' => trans('admin/v1/request.menu.component_path-present'),
            'component_path.max'     => trans('admin/v1/request.menu.component_path-max'),
            'is_enable.required'     => trans('admin/v1/request.menu.is_enable-required'),
            'is_enable.boolean'      => trans('admin/v1/request.menu.is_enable-boolean'),
        ];
    }
}
